package com.xywy.bloodandroid.adapter;

import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.xywy.bloodandroid.R;
import com.xywy.bloodandroid.act.ExpertsArticleAct;
import com.xywy.bloodandroid.base.BasicAdapter;
import com.xywy.bloodandroid.bean.ExpertArtail;

public class ExpertShareAdapter extends BasicAdapter<ExpertArtail> {
	private List<ExpertArtail> list;
	private Context context;
	private LayoutInflater inflater;
	private String id;

	public ExpertShareAdapter(Context context, List<ExpertArtail> list,
			 String id) {
		super(context, list);
		this.context = context;
		this.list = list;
		this.id = id;
		this.inflater = LayoutInflater.from(context);

	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		viewHolder holder = null;
		final int i = position;
		if (convertView == null) {
			holder = new viewHolder();

			convertView = inflater.inflate(R.layout.item_expert_exprence_share,
					null);
			holder.expert_share_text = (TextView) convertView
					.findViewById(R.id.expert_share_text);

			String title = list.get(i).getTitle();
			holder.expert_share_text.setText(title);
			convertView.setTag(holder);

		} else {
			holder = (viewHolder) convertView.getTag();
		}

		convertView.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				 Intent intent=new Intent(context, ExpertsArticleAct.class);
				 intent.putExtra("id", list.get(i).getId());
				 intent.putExtra("cateid", list.get(i).getCategoryid());
				 intent.putExtra("document_id", id);
				 context.startActivity(intent);
			}
		});
		return convertView;
	}

	public class viewHolder {

		TextView title;

		TextView address;
		TextView name;
		ImageView img1;

		TextView expert_share_text;// 文章标题
	}
}
